package com.example.riskmanage.service.impl;

import com.alibaba.fastjson.JSON;

import com.example.riskmanage.bean.Historylist;
import com.example.riskmanage.dao.HistorylistDao;
import com.example.riskmanage.service.HistorylistManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class HistorylistManagerImpl implements HistorylistManager {
    @Autowired
    HistorylistDao historylistDao;

    @Override
    public String getHistorylistService(Integer uid){
        HashMap<String,Object> map = new HashMap<>();

        //1.调用dao层接口获取数据
        List<Historylist> historylistList = historylistDao.findAllByUid(uid);
        //2.将处理的数据封装到map
        map.put("historylistList",historylistList);
        map.put("flag",true);


        String respJSON = JSON.toJSONString(map);
        return respJSON;
    }
    public String addHistorylistService(Historylist historylist){

        historylistDao.save(historylist);
        return "ok";
    }
    @Override
    public String deleteHistorylistService(Integer id){
        historylistDao.deleteById(id);
        return "ok";
    }

    @Override
    public String cmyHistorylistService(Integer id) {
        Historylist cmy=historylistDao.findHistorylistById(id);
        String respJSON = JSON.toJSONString(cmy);
        return respJSON;
    }


}
